<template>
  <view class="tab-bar-container">
    <view
      class="item"
      v-for="(item, index) in text"
      :key="item"
      @click="btnClick(index)"
      :class="{ activeColor: index === currentIndex }"
    >
      <text
        class="context"
        :class="{ active: index === 2, iconfont: index === 2, 'icon-jiahao': index === 2 }"
      >
        {{ item }}
      </text>
    </view>
  </view>
</template>

<script>
export default {
  name: 'TabBar',
  props: {
    currentIndex: {
      type: Number,
      default: -1
    }
  },
  data() {
    return { text: ['首页', '关注', '', '消息', '我'] }
  },

  methods: {
    btnClick(index) {
      switch (index) {
        case 0:
          uni.switchTab({ url: '/pages/index/index' })
          break
        case 1:
          uni.switchTab({ url: '/pages/follow/follow' })
          break
        case 2:
          uni.switchTab({ url: '/pages/Add/Add' })
          break
        case 3:
          uni.switchTab({ url: '/pages/Message/Message' })
          break
        case 4:
          uni.switchTab({ url: '/pages/Center/Center' })
          break
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.tab-bar-container {
  height: 98rpx;
  display: flex;
  font-size: 36rpx;
  background: rgba($color: #000000, $alpha: 0);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  .item {
    flex: 1;
    text-align: center;
    line-height: 98rpx;
    box-sizing: border-box;
    color: gray;
  }
  .active {
    background: #fff;
    border-radius: 20rpx;
    padding: 8rpx 40rpx;
    font-size: 40rpx;
    color: black;
  }

  .activeColor {
    color: #fff;
  }
}
</style>
